<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2019/5/21
  Time: 20:24
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<c:set var="path" value="${pageContext.request.contextPath}"></c:set>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">

    <title>商品秒杀页面</title>

    <link href="${path}/AmazeUI-2.4.2/assets/css/admin.css" rel="stylesheet" type="text/css" />
    <link href="${path}/AmazeUI-2.4.2/assets/css/amazeui.css" rel="stylesheet" type="text/css" />
    <link href="${path}/basic/css/demo.css" rel="stylesheet" type="text/css" />
    <link type="text/css" href="${path}/css/optstyle.css" rel="stylesheet" />
    <link type="text/css" href="${path}/css/style.css" rel="stylesheet" />

    <script type="text/javascript" src="${path}/basic/js/jquery-1.7.min.js"></script>
    <script type="text/javascript" src="${path}/basic/js/quick_links.js"></script>

    <!-- layui的js -->
    <script src="${path}/layuiadmin/layui/layui.js" charset="utf-8"></script>

    <script type="text/javascript" src="${path}/AmazeUI-2.4.2/assets/js/amazeui.js"></script>
    <script type="text/javascript" src="${path}/js/jquery.imagezoom.min.js"></script>
    <script type="text/javascript" src="${path}/js/jquery.flexslider.js"></script>
    <script type="text/javascript" src="${path}/js/list.js"></script>
    <!-- layui使用的样式-->
    <link rel="stylesheet" href="${path}/layuiadmin/layui/css/layui.css" media="all">
<!--自定义弹窗样式-->
    <link type="text/css" href="${path}/css/MyBoot.css" rel="stylesheet" />
    <!--验证码样式-->
    <style>
        .code
        {
            font-family:Arial;
            font-style:italic;
            color:cadetblue;
            font-size:15px;
            border:0;
            padding:2px 3px;
            letter-spacing:2px;
            font-weight:bolder;
            cursor:pointer;
            width:80px;
            height:30px;
            line-height:34px;
            text-align:center;
            vertical-align:middle;
            background-color:darkgrey;
        }

    </style>
</head>

<body>
<!-- 确认订单弹窗开始 -->
<div class="modaloo fadeoo inoo" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" >
    <div class="modal-dialogoo">
        <div class="modal-contentoo">
            <div class="modal-headeroo">

                <h4 class="modal-titleoo" id="myModalLabel" align="center">
                    确认订单

                </h4>
            </div>
            <div class="modal-bodyoo">
                <form id="update_form">
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label style="width: 30px;"></label><img src="" width="60px" height="60px" id="mymodelImg" ><label style="width: 30px;"></label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label id="suregoodsname" style="width: 120px">哈哈大开大合</label><label style="width: 30px;"></label>￥<label style="width: 20px;" id="surepice">2</label>x1<br/><br>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <label style="width: 120px;height: 20px;"><label style="width: 30px;"></label>购买数量</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label id="sureshopnum">1</label>件<br/>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <label style="width: 120px;height: 20px;"><label style="width: 30px;"></label>收货人</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label id="sureconsigneeusername"><input type="text" name="sureyzm" id="sureusername" placeholder="请输入收件人名字"></label><br/><br>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <label style="width: 120px;height: 20px;"><label style="width: 30px;"></label>收货地址</label>&nbsp;&nbsp;&nbsp;&nbsp;
                    <select name="provideId" id="provide">
                        <option value="0">选择省份</option>
                    </select>
                    <select name="cityId" id="cityId">
                    <option value="0">选择城市</option>
                    </select>
               <br/>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <label style="width: 120px;height: 20px;"><label style="width: 30px;"></label></label>&nbsp;&nbsp;&nbsp;&nbsp;
                    <select name="areaId" id="areaId">
                        <option value="0">选择地区</option>
                    </select>&nbsp;&nbsp;<input type="text" name="sureyzm" id="sureuseraddress" placeholder="详细地址：街道/镇，小区，门牌"><br/>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <label style="width: 120px;height: 20px;"><label style="width: 30px;"></label>联系方式</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label id="sureconsigneetel"><input type="text" name="sureyzm" id="sureusertel" placeholder="请输入手机号"></label><br/>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <label style="width: 120px;height: 32px;"><label style="width: 40px;"></label> <div id="checkCode" class="code"  onclick="createCode(6)" align="center"></div></label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label > <input type="text" name="sureyzm" id="sureyam" placeholder="请输入验证码"></label><br/>
                </form>
            </div>
            <div class="modal-footeroo" >
                <label style="width: 440px;"><button  type="button" class="btn btn-default" data-dismiss="modal" id="close_tangchuang">关闭
                </button><label style="width: 340px;" >合计：￥<label id="sumMoney">2</label></label></label>
                <label style="width: 80px;"><button type="button" class="btn btn-default" id="sure_update_save">
                    提交订单
                </button></label>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>


<!-- 修改弹窗结束 -->


<!--顶部导航条 -->
 <jsp:include page="header.jsp"></jsp:include>
<b class="line"></b>
<div class="listMain">

    <!--分类-->
    <div class="nav-table">
        <div class="long-title"><span class="all-goods">全部分类</span></div>
        <jsp:include page="navigation.jsp"></jsp:include>
    </div>
    <ol class="am-breadcrumb am-breadcrumb-slash">

    </ol>
    <script type="text/javascript">
       // $(function() {});
       // $(window).load(function() {
       //     $('.flexslider').flexslider({
       //         animation: "slide",
       //         start: function(slider) {
       //             $('body').removeClass('loading');
       //         }
       //     });
       // });
    </script>
    <div class="scoll">
        <section class="slider">
            <div class="flexslider">
                <ul class="slides">
                    <li>
                        <img src="${path}/images/01.jpg" title="pic" />
                    </li>
                    <li>
                        <img src="${path}/images/02.jpg" />
                    </li>
                    <li>
                        <img src="${path}/images/03.jpg" />
                    </li>
                </ul>
            </div>
        </section>
    </div>

    <!--放大镜-->

    <div class="item-inform">
        <div class="clearfixLeft" id="clearcontent">

            <div class="box">
                <script type="text/javascript">
                   // $(document).ready(function() {
                   //     $(".jqzoom").imagezoom();
                   //     $(document).on("click","#thumblist li a",function () {
                   //         $(this).parents("li").addClass("tb-selected").siblings().removeClass("tb-selected");
                   //         $(".jqzoom").attr('src', $(this).find("img").attr("mid"));
                   //         $(".jqzoom").attr('rel', $(this).find("img").attr("big"));
                   //     })
                   // });
                </script>

                <div class="tb-booth tb-pic tb-s310" >
                    <a id="tb_big_img" href="${path}/images/01.jpg"><img id="tb_big_img1" src="${path}/images/01.jpg" alt="细节展示放大镜特效" rel="${path}/images/01.jpg" class="jqzoom" /></a>
                </div>
                <ul class="tb-thumb" id="thumblist">

                </ul>
            </div>

            <div class="clear"></div>
        </div>

        <div class="clearfixRight">

            <!--规格属性-->
            <!--名称-->
            <div class="tb-detail-hd">
                <h1 id="goodsname">
                    良品铺子 手剥松子218g 坚果炒货 巴西松子
                </h1>
                <h3 id="goodstitle"></h3>
            </div>
            <div class="tb-detail-list">
                <!--价格-->
                <div class="tb-detail-price">

                    <li class="price iteminfo_price">
                        <dt>秒杀价</dt>
                        <dd><em>¥</em><b class="sys_item_price">56.90</b>  </dd>
                    </li>
                    <li class="price iteminfo_mktprice">
                        <dt>原价</dt>
                        <dd><em>¥</em><b class="sys_item_mktprice">98.00</b></dd>
                    </li>
                    <div class="clear"></div>
                </div>

                <div class="clear"></div>

                <!--销量-->
                <ul class="tm-ind-panel">
                    <li class="tm-ind-item tm-ind-sellCount canClick">
                        <div class="tm-indcon"><span class="tm-label">限&nbsp;</span><span class="tm-count" id="flashstocknum">1015</span><span class="tm-label">&nbsp;件</span></div>
                    </li>
                    <li class="tm-ind-item tm-ind-sumCount canClick">
                        <div class="tm-indcon"><span class="tm-label">已秒杀量&nbsp;</span><span class="tm-count" id="sellnum">6015</span></div>
                    </li>
                    <!--
                    <li class="tm-ind-item tm-ind-reviewCount canClick tm-line3">
                        <div class="tm-indcon"><span class="tm-label">累计评价</span><span class="tm-count">640</span></div>
                    </li>
                    -->
                </ul>
                <div class="clear"></div>

                <!--各种规格-->
                <dl class="iteminfo_parameter sys_item_specpara">
                    <dt class="theme-login"><div class="cart-title">可选规格<span class="am-icon-angle-right"></span></div></dt>
                    <dd>
                        <!--操作页面-->

                        <div class="theme-popover-mask"></div>

                        <div class="theme-popover">
                            <div class="theme-span"></div>
                            <div class="theme-poptit">
                                <a href="javascript:;" title="关闭" class="close">×</a>
                            </div>
                            <div class="theme-popbod dform">
                                <form class="theme-signin" name="loginform" action="" method="post">

                                    <div class="theme-signin-left">

                                      <div class="theme-options">
                                            <div class="cart-title"></div>
                                            <ul>
                                                <li class="sku-line"><i></i></li>
                                                <li class="sku-line"><i></i></li>
                                                <li class="sku-line"><i></i></li>
                                                <li class="sku-line"><i></i></li>
                                            </ul>
                                        </div>

                                        <div class="theme-options">
                                            <div class="cart-title number"> <font size="3"> 数量</font></div>
                    <dd>
                    <!--
                        <input id="min" class="am-btn am-btn-default" name="" type="button" value="-" />
                        <input id="text_box" name="" type="text" value="1" style="width:30px;" />
                        <input id="add" class="am-btn am-btn-default" name="" type="button" value="+" />-->
                    <span id="Stock1" class="tb-hidden">限购：<span class="stock">1</span>件</span>&nbsp;&nbsp;
                        <span id="Stock" class="tb-hidden">库存：<span class="stock" id="laststock">1000</span>件</span>
                        </dd>

            </div>
            <div class="clear"></div>
        </div>
        </form>
    </div>
</div>

</dd>
</dl>
<div class="clear"></div>
<!--活动	-->
<div class="shopPromotion gold">
    <div class="hot">
        <dt class="tb-metatit">该商品距结束还剩&nbsp;&nbsp;</dt>

        <div class="gold-list">
            <p id="downtime"> </p>
        </div>
    </div>
    <div class="clear"></div>

</div>
</div>

<ol class="am-breadcrumb am-breadcrumb-slash">
说明：&nbsp;&nbsp;不支持7天无理由退货&nbsp;&nbsp;不可使用优惠券
</ol>
<div class="pay">
    <div >


    </div>
    <li>
        <div class="clearfix tb-btn tb-btn-buy theme-login" id="clickBuyButton">
            <a id="LikBuy" title="点此按钮到下一步确认购买信息" href="javascript:;">立即购买</a>
        </div>
    </li>

</div>

</div>

<div class="clear"></div>

</div>

<!-- introduce-->

<div class="introduce">
    <div class="browse">
        <!---看了又看->
    <!--    <div class="mc">
            <ul>
                <div class="mt">
                    <h2>看了又看</h2>
                </div>

                <li class="first">
                    <div class="p-img">
                        <a  href="#"> <img class="" src="${path}/images/browse1.jpg"> </a>
                    </div>
                    <div class="p-name"><a href="#">
                        【三只松鼠_开口松子】零食坚果特产炒货东北红松子原味
                    </a>
                    </div>
                    <div class="p-price"><strong>￥35.90</strong></div>
                </li>
                <li>
                    <div class="p-img">
                        <a  href="#"> <img class="" src="${path}/images/browse1.jpg"> </a>
                    </div>
                    <div class="p-name"><a href="#">
                        【三只松鼠_开口松子】零食坚果特产炒货东北红松子原味
                    </a>
                    </div>
                    <div class="p-price"><strong>￥35.90</strong></div>
                </li>
                <li>
                    <div class="p-img">
                        <a  href="#"> <img class="" src="${path}/images/browse1.jpg"> </a>
                    </div>
                    <div class="p-name"><a href="#">
                        【三只松鼠_开口松子】零食坚果特产炒货东北红松子原味
                    </a>
                    </div>
                    <div class="p-price"><strong>￥35.90</strong></div>
                </li>
                <li>
                    <div class="p-img">
                        <a  href="#"> <img class="" src="${path}/images/browse1.jpg"> </a>
                    </div>
                    <div class="p-name"><a href="#">
                        【三只松鼠_开口松子】零食坚果特产炒货东北红松子原味
                    </a>
                    </div>
                    <div class="p-price"><strong>￥35.90</strong></div>
                </li>
                <li>
                    <div class="p-img">
                        <a  href="#"> <img class="" src="${path}/images/browse1.jpg"> </a>
                    </div>
                    <div class="p-name"><a href="#">
                        【三只松鼠_开口松子218g】零食坚果特产炒货东北红松子原味
                    </a>
                    </div>
                    <div class="p-price"><strong>￥35.90</strong></div>
                </li>

            </ul>
        </div>-->
    </div>
    <div class="introduceMain">
        <div class="am-tabs" data-am-tabs>
            <ul class="am-avg-sm-3 am-tabs-nav am-nav am-nav-tabs">
                <li class="am-active">
                    <a href="#">

                        <span class="index-needs-dt-txt">宝贝详情</span></a>

                </li>
                <!--猜你喜欢，全部评价-->
<!--
                <li>
                    <a href="#">

                        <span class="index-needs-dt-txt">全部评价</span></a>

                </li>

                <li>
                    <a href="#">

                        <span class="index-needs-dt-txt">猜你喜欢</span></a>
                </li>
                -->
            </ul>

            <div class="am-tabs-bd">

                <div class="am-tab-panel am-fade am-in am-active" id="babymessage">
                    <div class="J_Brand">

                        <div class="attr-list-hd tm-clear">
                            <h4>产品参数：</h4></div>
                        <div class="clear"></div>
                        <ul id="J_AttrUL">
                            <li title="">产品类型:&nbsp;烘炒类</li>
                            <li title="">原料产地:&nbsp;巴基斯坦</li>
                            <li title="">产地:&nbsp;湖北省武汉市</li>
                            <li title="">配料表:&nbsp;进口松子、食用盐</li>
                            <li title="">产品规格:&nbsp;210g</li>
                            <li title="">保质期:&nbsp;180天</li>
                            <li title="">产品标准号:&nbsp;GB/T 22165</li>
                            <li title="">生产许可证编号：&nbsp;QS4201 1801 0226</li>
                            <li title="">储存方法：&nbsp;请放置于常温、阴凉、通风、干燥处保存 </li>
                            <li title="">食用方法：&nbsp;开袋去壳即食</li>
                        </ul>
                        <div class="clear"></div>
                    </div>

                    <div class="details">
                        <div class="attr-list-hd after-market-hd">
                            <h4>商品细节</h4>
                        </div>
                        <div class="twlistNews">
                            <img src="${path}/images/tw1.jpg" />
                            <img src="${path}/images/tw2.jpg" />
                            <img src="${path}/images/tw3.jpg" />
                            <img src="${path}/images/tw4.jpg" />
                            <img src="${path}/images/tw5.jpg" />
                            <img src="${path}/images/tw6.jpg" />
                            <img src="${path}/images/tw7.jpg" />
                        </div>
                    </div>
                    <div class="clear"></div>

                </div>

            </div>

        </div>

        <div class="clear"></div>

        <div class="footer">

            <div class="footer-bd">
                <p>
                    <em>Copyright © 2006-2019 YONGHUI SUPERSTORES, All Rights Reserved小馋猫超市·版权所有  中国福建省厦门市软园24号  客服中心：86-591-83758880 4000601933</em>
                </p>
            </div>
        </div>
    </div>

</div>
</div>
<!--菜单 -->
<div class=tip>
    <div id="sidebar">
        <div id="wrap">
            <div id="prof" class="item">
                <a href="#">
                    <span class="setting"></span>
                </a>
                <div class="ibar_login_box status_login">
                    <div class="avatar_box">
                        <p class="avatar_imgbox"><img src="${path}/images/no-img_mid_.jpg" /></p>
                        <ul class="user_info">
                            <li>用户名：sl1903</li>
                            <li>级&nbsp;别：普通会员</li>
                        </ul>
                    </div>
                    <div class="login_btnbox">
                        <a href="order.html" class="login_order">我的订单</a>
                        <a href="collection.html" class="login_favorite">我的收藏</a>
                    </div>
                    <i class="icon_arrow_white"></i>
                </div>

            </div>
            <div id="shopCart" class="item">
                <a href="shopcart.html">
                    <span class="message"></span>
                </a>
                <p>
                    购物车
                </p>
                <p class="cart_num">0</p>
            </div>
            <div id="asset" class="item">
                <a href="#">
                    <span class="view"></span>
                </a>
                <div class="mp_tooltip">
                    我的资产
                    <i class="icon_arrow_right_black"></i>
                </div>
            </div>

            <div id="foot" class="item">
                <a href="#">
                    <span class="zuji"></span>
                </a>
                <div class="mp_tooltip">
                    我的足迹
                    <i class="icon_arrow_right_black"></i>
                </div>
            </div>

            <div id="brand" class="item">
                <a href="collection.html">
                    <span class="wdsc"><img src="${path}/images/wdsc.png" /></span>
                </a>
                <div class="mp_tooltip">
                    我的收藏
                    <i class="icon_arrow_right_black"></i>
                </div>
            </div>

            <div id="broadcast" class="item">
                <a href="#">
                    <span class="chongzhi"><img src="${path}/images/chongzhi.png" /></span>
                </a>
                <div class="mp_tooltip">
                    我要充值
                    <i class="icon_arrow_right_black"></i>
                </div>
            </div>

            <div class="quick_toggle">
                <li class="qtitem">
                    <a href="#"><span class="kfzx"></span></a>
                    <div class="mp_tooltip">客服中心<i class="icon_arrow_right_black"></i></div>
                </li>
                <!--二维码 -->
                <li class="qtitem">
                    <a href="#none"><span class="mpbtn_qrcode"></span></a>
                    <div class="mp_qrcode" style="display:none;"><img src="${path}/images/weixin_code_145.png" /><i class="icon_arrow_white"></i></div>
                </li>
                <li class="qtitem">
                    <a href="#top" class="return_top"><span class="top"></span></a>
                </li>
            </div>

            <!--回到顶部 -->
            <div id="quick_links_pop" class="quick_links_pop hide"></div>

        </div>

    </div>
    <div id="prof-content" class="nav-content">
        <div class="nav-con-close">
            <i class="am-icon-angle-right am-icon-fw"></i>
        </div>
        <div>
            我
        </div>
    </div>
    <div id="shopCart-content" class="nav-content">
        <div class="nav-con-close">
            <i class="am-icon-angle-right am-icon-fw"></i>
        </div>
        <div>
            购物车
        </div>
    </div>
    <div id="asset-content" class="nav-content">
        <div class="nav-con-close">
            <i class="am-icon-angle-right am-icon-fw"></i>
        </div>
        <div>
            资产
        </div>

        <div class="ia-head-list">
            <a href="#" target="_blank" class="pl">
                <div class="num">0</div>
                <div class="text">优惠券</div>
            </a>
            <a href="#" target="_blank" class="pl">
                <div class="num">0</div>
                <div class="text">红包</div>
            </a>
            <a href="#" target="_blank" class="pl money">
                <div class="num">￥0</div>
                <div class="text">余额</div>
            </a>
        </div>

    </div>
    <div id="foot-content" class="nav-content">
        <div class="nav-con-close">
            <i class="am-icon-angle-right am-icon-fw"></i>
        </div>
        <div>
            足迹
        </div>
    </div>
    <div id="brand-content" class="nav-content">
        <div class="nav-con-close">
            <i class="am-icon-angle-right am-icon-fw"></i>
        </div>
        <div>
            收藏
        </div>
    </div>
    <div id="broadcast-content" class="nav-content">
        <div class="nav-con-close">
            <i class="am-icon-angle-right am-icon-fw"></i>
        </div>
        <div>
            充值
        </div>
    </div>
</div>
<!--<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>-->

<script>
    var dataMessag;
    //alert("flashGoodsId:"+${flashGoodsId});
    //页面加载
    $(function () {
        var userid = "${user.userid}"+"a";
       // alert(userid)
        if(userid != "a") {
            layui.use(['laypage', 'layer'], function () {
                var laypage = layui.laypage, layer = layui.layer;
                //  layer.msg('玩命提示中');
                // layer.load(0, {shade: false});//0代表加载的风格，支持0-2

            })

           // alert(userid != "a")
            requestGoodsMessage();
        }else {
          //  alert("未登录")
            window.location.href="${path}/login";
        }
    })
    //**************Ajax请求获取商品详情信息***************
    function requestGoodsMessage() {
        $.ajax({
            url:"${path}/flashgoods.action/showFlashGoodsMessage",
            type:"GET",
            data:{
                flashGoodsId:"${flashGoodsId}"
            },
            success:function (data) {
                if(data.code==0){//有活动数据
                   // alert(data.data[0])
                    //数据展示模块
                    dataMessag = data.data[0];
                    showData(data.data[0]);
                    //倒计时模块
                    countDownTime(data.data[0])
                }else{//没有活动数据，返回错误信息
                    layui.use(['laypage', 'layer'], function () {
                        var laypage = layui.laypage, layer = layui.layer;

                        layer.msg(data.msg,{icon : 2,time : 1200});
                    })

                }
            },
            error:function () {
                layui.use(['laypage', 'layer'], function () {
                    var laypage = layui.laypage, layer = layui.layer;

                    layer.msg("客户端请求有误",{icon : 2,time : 1200});
                })

            }
        });
    }
    //*************倒计时模块**************
    function countDownTime(data) {
        var systemda = new Date().getTime();//系统当前时间
       var  downTime = parseInt(data.flashendtime)-systemda;

        $("#downtime").empty()

        var hh = 0 ;
        var mm = 0 ;
        var ss = 0 ;
        var time ="";
        if(downTime >=0){
            hh = parseInt(downTime /1000/3600);
            mm = parseInt((downTime-hh*1000*3600)/1000/60);
            ss = parseInt((downTime-hh*1000*3600-mm*1000*60)/1000);
            var h = ""+hh;
            var m = ""+mm;
            var s = ""+ss;
            if(h.length<=1){
                h = "0"+h;
            }
            if(m.length<=1){
                m = "0"+m;
            }
            if(s.length<=1){
                s = "0"+s;
            }
            time=h+"&nbsp;时&nbsp;"+m+"&nbsp;分&nbsp;"+s+"&nbsp;秒";
            $("#downtime").append(time);
            setTimeout(function () {
                countDownTime(data);
            },1000);
        }else {
            $("#downtime").append("该商品的秒杀活动已结束");
            //点击事件失效
            $("#LikBuy").attr("href","javascript:;")
        }
    }

    //******************数据展示模块***************
    function showData(data) {
        var flashgoodsprice = data.flashgoodsprice;//秒杀商品价格
        var goodsprice = data.goodsprice;//商品价格
        var goodsname = data.goodsname;//商品名
        var goodstitle = data.goodstitle;//商品标题
        var goodsinformation = data.goodsinformation;//商品详情
        var pictureurl = data.pictureurl;//商品图片路径
        var stocknum = data.stocknum;//商品总数
        var sellnum = data.sellnum; //库存
        var lastnum = stocknum - sellnum;//已秒杀

        //宝贝详情
        $("#babymessage").empty();
        $("#babymessage").append(goodsinformation);

        $("#goodsname").text(goodsname);
        $("#goodstitle").text(goodstitle);
        $(".sys_item_price").text(flashgoodsprice);
        $(".sys_item_mktprice").text(goodsprice);
        $("#laststock").text(sellnum)
        $("#flashstocknum").text(stocknum);
        $("#sellnum").text(lastnum);
       $("#tb_big_img").attr("href",pictureurl[0]);
        $("#tb_big_img1").attr("src",pictureurl[0]);
        $("#tb_big_img1").attr("rel",pictureurl[0]);
        //小图
        $("#thumblist").empty();
        $.each(pictureurl,function (i){
            $("#thumblist").append(' <li>'+
                '<div class="tb-pic tb-s40">'+
                '<a href="javascript:;"><img src="'+pictureurl[i]+'" mid="'+pictureurl[i]+'" big="'+pictureurl[i]+'"></a>'+
                '</div>'+
                '</li>');
        })
        $("#clickBuyButton").empty()
        $("#clickBuyButton").append('<a id="LikBuy" title="点此按钮到下一步确认购买信息" href="javascript:buyGoods('+data.flashgoodsid+','+data.flashendtime+','+data.flashstarttime+','+sellnum+');">立即购买</a>')

    }
    //********************点击立即购买按钮***************************
    function buyGoods(flashgoodsid,endtime,starttime,sellnum) {
        var systemda = new Date().getTime();//系统当前时间
      //  alert("￥"+endtime+"num"+starttime+"flashsaleid"+flashgoodsid+"mmm:"+sellnum)
            if(sellnum<=0){
                layui.use(['laypage', 'layer'], function () {
                    var laypage = layui.laypage, layer = layui.layer;

                    layer.msg("该商品库存不足，购买失败。感谢你的关注。",{icon : 2,time : 1200});
                })

            }else{
                if(systemda<starttime||systemda>endtime){
                    layui.use(['laypage', 'layer'], function () {
                        var laypage = layui.laypage, layer = layui.layer;

                        layer.msg("该商品不在秒杀时间段内，请耐心等待",{icon : 2,time : 1200});
                    })

                }else {
                    <!--开启弹窗事件-->
                    //产品图
                    $("#mymodelImg").attr("src",dataMessag.pictureurl[0])
                    $("#suregoodsname").text(dataMessag.goodsname)
                    $("#surepice").text(dataMessag.flashgoodsprice)
                    $("#sumMoney").text(dataMessag.flashgoodsprice);
                    //产生验证码
                    createCode(6);
                    //省份第一级联动
                    provinceMessage()
                    $("#myModal").attr("style","display: block; padding-left: 400px;top:100px; width:980px;");
                }

            }
    }

    <!--关闭确认订单弹窗事件-->
    $("#close_tangchuang").click(function(){
        close();
    });

    function close(){
        document.getElementById("update_form").reset();
        $('#provide').empty()
        $("#provide").append('<option value ="0">选择省份</option>')
        $("#areaId").empty();
        $("#areaId").append('<option value="0">选择地区</option>');
        $("#cityId").empty()
        $("#cityId").append('<option value="0">选择城市</option>');
        $("#myModal").attr("style","display: none; padding-left: 417px;top:100px; width:900px;");
    }
    //*************Ajax请求中国省份信息**********************
    function provinceMessage() {
        $.ajax({
            url:"${path}/province.action/findAllProvince",
            type:"GET",
            dataType:"json",
            success:function (data) {
                if(data.code==0){//有省份数据
                    var message = data.data
                    $('#provide').empty()
                    $("#provide").append('<option value ="0">选择省份</option>')
                    $("#areaId").empty();
                    $("#areaId").append('<option value="0">选择地区</option>');
                    $.each(message,function (i) {
                        $('#provide').append('<option value="'+message[i].provinceid+'">'+message[i].provincename+'</option>');
                    })
                }else{//没有活动数据，返回错误信息

                    layui.use(['laypage', 'layer'], function () {
                        var laypage = layui.laypage, layer = layui.layer;

                        layer.msg(data.msg,{icon : 2,time : 1200});
                    })
                }
            },
            error:function () {
                layui.use(['laypage', 'layer'], function () {
                    var laypage = layui.laypage, layer = layui.layer;

                    layer.msg("客户端请求异常",{icon : 2,time : 1200});
                })

            }
        })
    }

    //*******************获取城市信息*************
   $('#provide').blur(function () {
       $("#areaId").empty();
       $("#areaId").append('<option value="0">选择地区</option>');
      var i = $(this).val()
       if(i=="" || i== 0){
          $("#cityId").empty();
          $("#cityId").append('<option value="0">选择城市</option>');
           $("#areaId").empty();
           $("#areaId").append('<option value="0">选择地区</option>');
           layui.use(['laypage', 'layer'], function () {
               var laypage = layui.laypage, layer = layui.layer;

               layer.msg("还未选择省份",{icon : 2,time : 1200});
           })
       }else{

       $("#cityId").empty();
       $("#cityId").append('<option value ="0">选择城市</option>')
       $.ajax({
           url:"${path}/city.action/findCityByProNum",
           type:"GET",
           dataType:"json",
           data:{
               proNum:$(this).val()
           },
           success:function (data) {
               if(data.code==0){//有省份数据
                   var message = data.data
                   $('#cityId').empty()
                   $.each(message,function (i) {
                       $('#cityId').append('<option value="'+message[i].cityid+'">'+message[i].cityname+'</option>');
                   })
               }else{//没有活动数据，返回错误信息
                   layui.use(['laypage', 'layer'], function () {
                       var laypage = layui.laypage, layer = layui.layer;

                       layer.msg(data.msg,{icon : 2,time : 1200});
                   })

               }
           },
           error:function () {
               layui.use(['laypage', 'layer'], function () {
                   var laypage = layui.laypage, layer = layui.layer;

                   layer.msg("客户端请求异常",{icon : 2,time : 1200});
               })

           }
       })
       }
   })
    //*******************获取地区信息*************
    $('#cityId').blur(function () {
        var cit = $(this).val()
            if ( cit == "" ||  cit == 0) {
                layui.use(['laypage', 'layer'], function () {
                    var laypage = layui.laypage, layer = layui.layer;

                    layer.msg("还未选择上级城市",{icon : 2,time : 1200});
                })

            } else {

                $("#areaId").empty();
                $("#areaId").append('<option value ="0">选择地区</option>')
                $.ajax({
                    url: "${path}/area.action/findAreaByCityNum",
                    type: "GET",
                    dataType: "json",
                    data: {
                        cityNum: $(this).val()
                    },
                    success: function (data) {
                        if (data.code == 0) {//有省份数据
                            var message = data.data
                            $('#areaId').empty()
                            $.each(message, function (i) {
                                $('#areaId').append('<option value="' + message[i].areaid + '">' + message[i].areaname + '</option>');
                            })
                        } else {//没有活动数据，返回错误信息
                            layui.use(['laypage', 'layer'], function () {
                                var laypage = layui.laypage, layer = layui.layer;

                                layer.msg(data.msg,{icon : 2,time : 1200});
                            })
                        }
                    },
                    error: function () {
                        layui.use(['laypage', 'layer'], function () {
                            var laypage = layui.laypage, layer = layui.layer;

                            layer.msg("客户端请求异常",{icon : 2,time : 1200});
                        })

                    }
                })

            }

    })

    //*****************手机失焦校验*******************
    $("#sureusertel").blur(function () {
        var tel = $("#sureusertel").val()
        var reg = new RegExp("^(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\\d{8}$","ig");
       if(!reg.test(tel)){
           layui.use(['laypage', 'layer'], function () {
               var laypage = layui.laypage, layer = layui.layer;
               layer.msg("手机号格式不对",{icon : 2,time : 1200});

           })
       }

    })

    //*****************提交订单****************
    $("#sure_update_save").click(function () {
        var flag =true;
        var sureusername= $("#sureusername").val();     //收件人名字
        var sureshopnum = $("#sureshopnum").text();     //秒杀数量
        var surepice =$("#surepice").text();            //秒杀价格
        var userid = "${user.userid}"                    //秒杀用户ID
        var sureusertel =$("#sureusertel").val()        //手机号
        var provinceid = $("#provide").val();           //省份
        var cityid = $("#cityId").val();                //城市
        var areaid = $("#areaId").val();                 //地区
        var address = $("#sureuseraddress").val();       //详细地址
        var flashgoodsid = dataMessag.flashgoodsid;        //秒杀商品ID
        var allmoney = $("#sumMoney").text()               //总价
        //获取显示区生成的验证码
       // var checkCode = document.getElementById("checkCode").innerHTML;
        var checkCode = $("#checkCode").text()
        //获取输入的验证码
        var inputCode = $("#sureyam").val();
        if(checkCode != inputCode){
            flag = false;
            $("#sureyam").attr("value" ,"");
            createCode(6);
            layui.use(['laypage', 'layer'], function () {
                var laypage = layui.laypage, layer = layui.layer;
                layer.msg("验证码不正确,请重新输入,<br>点击图片可刷新",{icon : 2,time : 1200});
            })
        }

        var tel = $("#sureusertel").val()
        var reg = new RegExp("^(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\\d{8}$","ig");
        if(!reg.test(tel)){
            flag =false;
            layui.use(['laypage', 'layer'], function () {
                var laypage = layui.laypage, layer = layui.layer;
                layer.msg("手机格式不正确",{icon : 2,time : 1200});
            })
        }
        if(sureusername==""){
            flag = false;
            layui.use(['laypage', 'layer'], function () {
                var laypage = layui.laypage, layer = layui.layer;
                layer.msg("收货人为必填项",{icon : 2,time : 1200});
            })
        }
        if(provinceid==""||areaid==""||cityid==""||address==""){
            flag = false;
            layui.use(['laypage', 'layer'], function () {
                var laypage = layui.laypage, layer = layui.layer;
                layer.msg("收货地址为必填项",{icon : 2,time : 1200});
            })
        }
        if(userid==""){
            flag = false;
            layui.use(['laypage', 'layer'], function () {
                var laypage = layui.laypage, layer = layui.layer;
                layer.msg("请先登录再进行秒杀",{icon : 2,time : 1200},function () {
                    //跳回登录页面
                    window.location.href="${path}/user.action/login";
                });
            })
        }
        //获取秒杀路径
        if(flag){
         getFlashPath(userid,flashgoodsid)
        }

    })
    //获取隐藏路径
    function getFlashPath(uid,flashgoodsid) {
        $.ajax({
            url: "${path}/flashgoods.action/bulidpath",
            type: "POST",
            dataType: "json",
            data: {
                userId: uid,
                flashgoodsId:flashgoodsid
            },
            success: function (data) {
                if(data.code==0){
                  var  flashPath = data.data[0]
                    flashing(flashPath)
                }else{
                    layui.use(['laypage', 'layer'], function () {
                        var laypage = layui.laypage, layer = layui.layer;
                        layer.msg(data.msg,{icon : 2,time : 1200});
                    })
                }
            },
            error:function () {
                layui.use(['laypage', 'layer'], function () {
                    var laypage = layui.laypage, layer = layui.layer;
                    layer.msg("客户端请求异常",{icon : 2,time : 1200});
                })
            }
        })

    }
    <!--进行秒杀-->
function flashing(path) {
    $.ajax({
        url:"${path}/flashgoods.action/"+path+"/bulidpath",
        type:"post",
        dataType:"json",
        data:{
            sureusername: $("#sureusername").val(),
            sureshopnum:$("#sureshopnum").text(),
            surepice:$("#surepice").text(),
            userid:"${user.userid}",
            sureusertel:$("#sureusertel").val(),
            provinceid:$("#provide").val(),
            cityid:$("#cityId").val(),
            areaid:$("#areaId").val(),
            address:$("#sureuseraddress").val(),
            flashgoodsid:dataMessag.flashgoodsid,
            goodid:dataMessag.goodsid,
            allmoney:$("#sumMoney").text()
        },
        success:function (data) {
            if(data.code==0){//秒杀数据
              if(data.data[0]==0){
                // layer.load(0, {shade: false});//0代表加载的风格，支持0-2
                  getResult(dataMessag.flashgoodsid);
               // alert("秒杀成功")

              }
                //返回秒杀情况
            }else{//没有活动数据，返回错误信息
                layui.use(['laypage', 'layer'], function () {
                    var laypage = layui.laypage, layer = layui.layer;

                    layer.msg(data.msg,{icon : 2,time : 1200});
                })
            }
        },
        error:function () {
            layui.use(['laypage', 'layer'], function () {
                var laypage = layui.laypage, layer = layui.layer;

                layer.msg("客户端请求异常",{icon : 2,time : 1200});
            })
        }
    })
}

<!--请求是否下单完成 0：排队中，1：秒杀成功，2：秒杀失败-->
function getResult(fgid) {
    $.ajax({
        url:"${path}/flashgoods.action/getresult",
        type:"POST",
        data:{
            uid:"${user.userid}",
            fgid:fgid
        },
        success:function (data) {
            //关闭弹窗
            close();
            if(data.code==0){//有活动数据
                if(data.data[0]==0){//继续轮询
                    layer.msg("下单中。。。")
                    setTimeout(function () {//定时器
                        getResult(fgid);
                    },300);
                }else {//下单成功咨询是否要去查看订单
                    layer.confirm('恭喜您，秒杀成功！', {
                        btn: ['立即支付','查看订单'] //按钮
                    }, function(){//立即支付事件
                            goingPlay(data.data[0])
                    }, function(){//查看订单事件
                       // 前往订单详情界面查看订单

                            window.location.href="${path}/user.action/flashOrderInfo?orderNum="+data.data[0];
                    });
                }
            }else{//下单失败，返回错误信息
                layui.use(['laypage', 'layer'], function () {
                    var laypage = layui.laypage, layer = layui.layer;
                    layer.msg(data.msg,{icon : 2,time : 1200});
                })

            }
        }
    });
}

    //***********************前往支付***********************
    function goingPlay(flashorderid) {
       // alert("dshk")
        $.ajax({
            url:"${path}/flashorder.action/updateuserpay",
            type:"GET",
            data:{

                uid:"${user.userid}",
                foid :flashorderid
            },
            success:function (data) {
                if(data.code==0){//有活动数据
                    layui.use(['laypage', 'layer'], function () {
                        var laypage = layui.laypage, layer = layui.layer;
                        layer.msg("支付成功",{icon : 1,time : 1200},function () {
                            //进行页面刷新
                            requestGoodsMessage();
                        });
                    })
                    //alert(data.data);
                    // showtodayFlashSale(data.data);
                }else{//没有活动数据，返回错误信息
                    layui.use(['laypage', 'layer'], function () {
                        var laypage = layui.laypage, layer = layui.layer;

                        layer.msg(data.msg,{icon : 1,time : 1200},function () {
                            //进行页面刷新
                            requestGoodsMessage();
                        });
                    })
                }
            },
            error:function () {
                layui.use(['laypage', 'layer'], function () {
                    var laypage = layui.laypage, layer = layui.layer;
                    layer.msg("支付失败",{icon : 1,time : 1200},function () {
                        //进行页面刷新
                        requestGoodsMessage();
                    });
                })
            }
        });
    }
</script>




<!--验证码-->
<script type="text/javascript">

    //生成验证码的方法
    function createCode(length) {
        var code = "";
        var codeLength = parseInt(length); //验证码的长度
        var checkCode = document.getElementById("checkCode");
        ////所有候选组成验证码的字符，当然也可以用中文的
        var codeChars = new Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
            'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
            'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
        //循环组成验证码的字符串
        for (var i = 0; i < codeLength; i++)
        {
            //获取随机验证码下标
            var charNum = Math.floor(Math.random() * 62);
            //组合成指定字符验证码
            code += codeChars[charNum];
        }
        if (checkCode)
        {
            //为验证码区域添加样式名
            checkCode.className = "code";
            //将生成验证码赋值到显示区
            checkCode.innerHTML = code;
        }
    }
</script>

</body>

</html>
